<?php

namespace App\Console;

use App\Console\Commands\BuildPeriod;
use App\Console\Commands\CalcAgeByID;
use App\Console\Commands\VerifyHistoryPeriod;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
use Illuminate\Support\Facades\Log;

class Kernel extends ConsoleKernel
{
    /**
     * The Artisan commands provided by your application.
     *
     * @var array
     */
    protected $commands = [
        BuildPeriod::class,
        CalcAgeByID::class,
        VerifyHistoryPeriod::class
    ];

    /**
     * Define the application's command schedule.
     *
     * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
     * @return void
     */
    protected function schedule(Schedule $schedule)
    {
        // $schedule->command('inspire')
        //          ->hourly();
        $schedule->command('calc:age')->dailyAt('1:0');
        $schedule->command('build:period')->monthlyOn(20, '0:0');
        $schedule->command('verify:history-period')->monthlyOn(20, '12:00');
        $schedule->command('dorm-type:auto_fix')->dailyAt('0:30');
        if (env('APP_DEBUG')) {
            Log::info('schedule run');
        }
    }

    /**
     * Register the commands for the application.
     *
     * @return void
     */
    protected function commands()
    {
        $this->load(__DIR__ . '/Commands');

        require base_path('routes/console.php');
    }
}
